package com.duan.normal.service.impl;

import com.duan.normal.beans.po.ProductPo;
import com.duan.normal.mapper.ProductMapper;
import com.duan.normal.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * Created by duanlsh on 18/6/17.
 */
@Service
public class ProductServiceImpl implements ProductService {


    @Autowired
    private ProductMapper productMapper;

    @Override
    public void insert(ProductPo productInfo) {
        if (productInfo == null) {
            productInfo = new ProductPo();
        }
//        productInfo.setProductId(UUID.randomUUID().toString().replace("-",""));
//        productInfo.setProductName("商品1");
//        productInfo.setProductPrice("22.33");
//        productInfo.setProductCategory("1");
//        productInfo.setProductStock("1000");
//        Integer result = productMapper.insert(productInfo);
//        System.out.println("result ----- " + result);

        List<ProductPo> list = productMapper.list();

        System.out.println("=============");
        list.forEach(e -> System.out.println(e.getProductId()));
        list = productMapper.listXML();
        list.forEach(e -> System.out.println(e.getProductId() + "--- " + e.getProductName()));

    }
}
